﻿<phone:PhoneApplicationPage
    x:Class="NiklasKarl.WarpCam.Pages.PreviewPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator Text="Picture successfully saved to Camera Roll"
                                 IsIndeterminate="False" Value="0" IsVisible="True"/>
    </shell:SystemTray.ProgressIndicator>
    
    <phone:PhoneApplicationPage.Resources>
        <Storyboard x:Name="ResetStoryboard">
            <DoubleAnimation x:Name="ResetScaleXAnimation" Storyboard.TargetName="PreviewImageTransform" Storyboard.TargetProperty="ScaleX"
                             FillBehavior="HoldEnd">
                <DoubleAnimation.EasingFunction>
                    <ExponentialEase EasingMode="EaseIn" Exponent="2"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
            <DoubleAnimation x:Name="ResetScaleYAnimation" Storyboard.TargetName="PreviewImageTransform" Storyboard.TargetProperty="ScaleY"
                             FillBehavior="HoldEnd">
                <DoubleAnimation.EasingFunction>
                    <ExponentialEase EasingMode="EaseIn" Exponent="2"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
            <DoubleAnimation x:Name="ResetTranslateXAnimation" Storyboard.TargetName="PreviewImageTransform" Storyboard.TargetProperty="TranslateX"
                             FillBehavior="HoldEnd">
                <DoubleAnimation.EasingFunction>
                    <ExponentialEase EasingMode="EaseIn" Exponent="2"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
            <DoubleAnimation x:Name="ResetTranslateYAnimation" Storyboard.TargetName="PreviewImageTransform" Storyboard.TargetProperty="TranslateY"
                             FillBehavior="HoldEnd">
                <DoubleAnimation.EasingFunction>
                    <ExponentialEase EasingMode="EaseIn" Exponent="2"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>
    </phone:PhoneApplicationPage.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource AppBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Border x:Name="PreviewImageContainer" Grid.Row="1" Background="Transparent"
                ManipulationStarted="PreviewImageContainer_ManipulationStarted"
                ManipulationDelta="PreviewImageContainer_ManipulationDelta"
                ManipulationCompleted="PreviewImageContainer_ManipulationCompleted">
            <Image x:Name="PreviewImage" Stretch="Uniform" IsHitTestVisible="False"
                   HorizontalAlignment="Center" VerticalAlignment="Center">
                <Image.RenderTransform>
                    <CompositeTransform x:Name="PreviewImageTransform" CenterX="240" CenterY="318"/>
                </Image.RenderTransform>
            </Image>
        </Border>

        <Border Grid.Row="0" Background="{StaticResource AppAccentBrush3}">
            <StackPanel Margin="12,0,0,0" Orientation="Horizontal">
                <Image Source="/Assets/ApplicationIcon (32x32).png" Width="32" Height="32" Margin="12,0"/>
                <TextBlock Text="WARP CAM - PREVIEW" Style="{StaticResource PhoneTextNormalStyle}" Margin="0,17,0,16" Foreground="{StaticResource AppForegroundBrush}"/>
            </StackPanel>
        </Border>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar BackgroundColor="{StaticResource AppAccentColor3}" ForegroundColor="{StaticResource AppForegroundColor}">
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton Text="share" IconUri="/Assets/AppBar/share.png" Click="ShareButton_Click"/>
            </shell:ApplicationBar.Buttons>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    
</phone:PhoneApplicationPage>